package com.gimi.cloud.bbp.common.utils;

import java.util.List;

/**
 * Created by shazhiwei on 2017/12/18.
 */
public class StateUtil {
    /**
     * 转换性别
     */
    public static String changeSex(Integer sex){
        String result = "未知";
        if(sex != null){
            if(sex == 1){
                result = "男";
            }else if (sex == 2){
                result = "女";
            }
        }
        return result;
    }

    /**
     * 转换 是 否
     */
    public static String changeYesOrNo(Integer state){
        String result = "未知";
        if(state != null){
            if(state == 0){
                result = "否";
            }else if(state == 1){
                result = "是";
            }
        }
        return result;
    }

    /**
     * 转换用户状态
     */
    public static String changeMasterState(Integer state){
        String result = "未知";
        if(state != null){
            if(state == 0){
                result = "禁用";
            }else if(state == 1){
                result = "启用";
            }
        }
        return result;
    }

    /**
     * 转换用户状态
     */
    public static String changeMasterState(List<Integer> list){
        StringBuilder sb = new StringBuilder();
        sb.append("(");
        if(list != null && list.size() > 0){
            for(Integer num : list){
                sb.append(num).append(",");
            }
            sb.delete(sb.length()-1,sb.length());
        }
        sb.append(")");
        return sb.toString();
    }

    /**
     * 转换商品状态
     */
    public static String changeProductStatus(Integer status){
        String result = "未知";
        if(status != null){
            switch (status){
                case 1: result = "上架";break;
                case 2: result = "待上架";break;
                case 3: result = "预览";break;
                case 4: result = "删除";break;
                default:break;
            }
        }
        return result;
    }

}
